/*************************************************************************
	> File Name: hzoj_285.cpp
	> Author: zhangxu
	> Mail: 
	> Created Time: 五  8/23 05:32:40 2024
 ************************************************************************/

#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

priority_queue<int, vector<int>, less<int>> q;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> temp(m, 0);
	for(int i = 0; i < n; i++) {
		if(i == 0) {
			for(int j = 0, a; j < m; j++) {
				cin >> a;
				q.push(a);
			}
		} else {
			for(int j = 0, a; j < m; j++) {
				cin >> a;
				for(auto x : temp) {
					if(q.size() < m || q.top() > x + a) {
						q.push(x + a);	
					}
					if(q.size() > m)
						q.pop();
				}
			}
		}
		for(int k = 0; k < m && !q.empty(); k++) {
			temp[k] = q.top();
			q.pop();
		}
	}
	int flag = 0;
	for(auto it = temp.rbegin(); it != temp.rend(); it++) {
		if(flag) cout << " ";
		cout << *it;
		flag = 1;
	}
	cout << endl;
	return 0;
}